import { MockMethod } from "vite-plugin-mock";

const menus = [
	{
		icon: "HomeOutlined",
		path: "/home/index",
		title: "首页"
	},
	{
		icon: "PieChartOutlined",
		path: "/echarts",
		title: "Echarts",
		children: [
			{
				icon: "AppstoreOutlined",
				path: "/echarts/lineChart",
				title: "折线图"
			},
			{
				icon: "AppstoreOutlined",
				path: "/echarts/barChart",
				title: "柱状图"
			}
		]
	}
];

const userMock: Array<MockMethod> = [
	{
		url: "/api/login",
		method: "post",
		response: config => {
			const { username, password } = config.body;
			if (username === "admin" && password === "123456") {
				return {
					code: 200,
					msg: "登录成功",
					data: {
						token: "test-12"
					}
				};
			} else {
				return {
					code: -1,
					msg: "账号或密码错误"
				};
			}
		}
	},
	{
		url: "/api/menus",
		method: "get",
		response() {
			return {
				code: 200,
				data: menus,
				msg: "成功"
			};
		}
	}
];

export default userMock;
